<?php

namespace App\Wechat\Remind\Controllers;

use App\Wechat\Remind\Logics\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class AuthController extends Controller
{
	public function login(Request $request)
	{
		$code = $request->post('code', '');
		$iv = $request->post('iv', '');
		$encryptedData = $request->post('encryptedData', '');
		$result = (new Auth())->userLogin($code, $iv, $encryptedData);
		return response()->json($result);
    }

	public function logout()
	{
		auth()->guard('remind')->logout();
		return response()->json(['message' => 'Successfully logged out']);
    }

	public function refresh()
	{
		$result = (new Auth())->refreshToken();
		return response()->json($result);
    }
}
